//
//  ZCBaseScrollerView.m
//  VoiceMusic
//
//  Created by dllo on 15/10/16.
//  Copyright © 2015年 zhangdeyu. All rights reserved.
//

#import "ZCBaseScrollerView.h"
#import "ZCMainModel.h"
#import <UIImageView+WebCache.h>

@implementation ZCBaseScrollerView

-(void)playImage:(UIScrollView *)scrollView
        imageArr:(NSMutableArray *)imageArr
{
    
    scrollView.contentSize = CGSizeMake((imageArr.count + 2) * WIDTH, 0);
    
    for (NSInteger i = 1; i<imageArr.count+1; i++) {
        ZCMainModel *model = imageArr[i-1];
        UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH*i, 0, WIDTH, 200)];
        NSString *url = @"";
        if([model.picUrl length] > 90){
            
           url = [model.picUrl substringToIndex:90];
    
        }else{
            url = model.picUrl;
        }
    
        [image sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"2008114171429640_2"]];
        image.tag = i;
        [scrollView addSubview:image];
    }
    
    ZCMainModel *model = imageArr[imageArr.count-1];
    UIImageView *topImage = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,WIDTH,200)];
    
     NSString *url = @"";
    if([model.picUrl length] > 90){
        
        url = [model.picUrl substringToIndex:90];
        
    }else{
        url = model.picUrl;
    }
    
    [topImage sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"2008114171429640_2"]];
    topImage.tag = imageArr.count;
    [scrollView addSubview:topImage];
  
    ZCMainModel *buttonModel = imageArr[0];
    UIImageView *buttonImage = [[UIImageView alloc] initWithFrame:CGRectMake(WIDTH*(imageArr.count+1),0,WIDTH,200)];
    
    NSString *urll = @"";
    if([model.picUrl length] > 90){
        
        urll = [buttonModel.picUrl substringToIndex:90];
        
    }else{
        urll = buttonModel.picUrl;
    }
    
    [buttonImage sd_setImageWithURL:[NSURL URLWithString:urll] placeholderImage:[UIImage imageNamed:@"2008114171429640_2"]];
    buttonImage.userInteractionEnabled=YES;
    buttonImage.tag = 1;
    [scrollView addSubview:buttonImage];

}


@end
